﻿// Sheego.Service.X400
// Copyright(C) 2015 Schwab Versand GmbH
//
// This source file is subject to the Microsoft Public License(Ms-PL).
// http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.

using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Castle.Windsor.Installer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sheego.Service.X400.Scheduler.Shared.Locator
{
    public class SchedulerLocator
    {
        private static WindsorContainer _container = null;
        private static WindsorContainer Container
        {
            get
            {
                if (_container == null)
                {
                    _container = new WindsorContainer();
                    _container.Install(FromAssembly.Named("Sheego.Service.X400.Scheduler.Impl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0c657262f77b6bfb"));
                }
                return _container;
            }
        }

        public static void Reset()
        {
            _container = null;
        }


        public static void Register<T1>(T1 instance) where T1 : class
        {
            Container.Register(Component.For<T1>().Instance(instance).IsDefault());
        }


        public static IScheduler GetScheduler()
        {
            return Container.Resolve<IScheduler>();
        }



        public static ISchedulerLogger GetSchedulerLogger()
        {
            return Container.Resolve<ISchedulerLogger>();
        }
    }
}
